package com.leetcode.Stack;



public class Leetcode167 {

    public int[] twoSum(int[] numbers, int target) {
        int[] res = new int[2];
        int l = 0;
        int r = numbers.length-1;
        while (l < r) {
            int sum = numbers[l] + numbers[r];
            if (sum < target) {
                l++;
            } else if (sum > target) {
                r--;
            } else {
                res[0] = l;
                res[1] = r;
            }
        }
        return res;
    }

    public static void main(String[] args) {
        Leetcode167 leet = new Leetcode167();
        int[] arr = {0, 0, 3 ,4};
        int target = 0;
        leet.twoSum(arr, target);
    }

}
